<?php declare(strict_types=1);
/**
 * @author      xianganyall <xianganyall@gmail.com>
 * @copyright   2023-2025 owner
 **/

namespace Srv\Libs\Plugins\MapGeo;

class Bounds
{
    public float $minX          = 0.0;  // 矩形左下角的x坐标
    public float $minY          = 0.0;  // 矩形左下角的y坐标
    public float $maxX          = 0.0;  // 矩形右上角的x坐标
    public float $maxY          = 0.0;  // 矩形右上角的y坐标

    /**
     * @param Point $sw
     * @param Point $ne
     * __construct
     */
    public function __construct(Point $sw, Point $ne)
    {
        $this->minX = $sw->lng;
        $this->minY = $sw->lat;
        $this->maxX = $ne->lng;
        $this->maxY = $ne->lat;
    }

    /**
     * @return Point
     * 返回矩形区域的西南角
     */
    public function getSouthWest():Point
    {
        return new Point($this->minX, $this->minY);
    }

    /**
     * @return Point
     * 返回矩形区域的东北角
     */
    public function getNorthEast():Point
    {
        return new Point($this->maxX, $this->maxY);
    }
}